﻿namespace ArticleContentCreate.Utils.Enhance.EditHelper
{
    internal class HtmlCodeCreate
    {
        /// <summary>
        /// 创建基础的HTML标签，返回<xx>{0}</xx>
        /// </summary>
        /// <param name="LableName"></param>
        /// <returns></returns>
        public string BasicsCode(string LableName)
        {
            return BasicsCode(LableName, "");
        }

        /// <summary>
        /// 基础标签创建，请参考：<{0} {1}>{2}</{0}>
        /// </summary>
        /// <param name="LableName">标签名字</param>
        /// <param name="Extend">扩展内容</param>
        /// <returns></returns>
        public string BasicsCode(string LableName, string Extend)
        {
            return string.Format("<{0}{1}>{2}</{0}>", LableName, Extend, "{0}");
        }

        /// <summary>
        /// 创建属性内容
        /// </summary>
        /// <param name="Lable"></param>
        /// <param name="Content"></param>
        /// <returns></returns>
        public string AttributeCode(string Lable, string Content)
        {
            return string.Format(" {0}=\"{1}\" ", Lable, Content);
        }

        /// <summary>
        /// 创建IMG标签
        /// </summary>
        /// <param name="Imgsrc"></param>
        /// <returns></returns>
        public string LableImg(string Imgsrc)
        {
            return string.Format(BasicsCode("img", AttributeCode("src", Imgsrc)).Replace("{0}", ""), "");
        }

        /// <summary>
        /// 创建IMG标签
        /// </summary>
        /// <param name="Imgsrc"></param>
        /// <param name="ClassName"></param>
        /// <returns></returns>
        public string LableImg(string Imgsrc, string ClassName)
        {
            return string.Format(BasicsCode("img", AttributeCode("src", Imgsrc) + AttributeCode("class", ClassName)), "");
        }

        /// <summary>
        /// 创建P标签
        /// </summary>
        /// <param name="Content"></param>
        /// <returns></returns>
        public string LableP(string Content)
        {
            return string.Format(BasicsCode("p"), Content);
        }

        /// <summary>
        /// 创建P标签
        /// </summary>
        /// <param name="Content"></param>
        /// <param name="Class"></param>
        /// <returns></returns>
        public string LableP(string Content, string ClassName)
        {
            return string.Format(BasicsCode("p", AttributeCode("class", ClassName)), Content);
        }

        /// <summary>
        /// 创建Div标签
        /// </summary>
        /// <param name="Content"></param>
        /// <returns></returns>
        public string LableDiv(string Content)
        {
            return string.Format(BasicsCode("div"), Content);
        }

        /// <summary>
        /// 创建Div标签
        /// </summary>
        /// <param name="Content"></param>
        /// <param name="Class"></param>
        /// <returns></returns>
        public string LableDiv(string Content, string ClassName)
        {
            return string.Format(BasicsCode("div", AttributeCode("class", ClassName)), Content);
        }

        /// <summary>
        /// 创建A标签
        /// </summary>
        /// <param name="Content"></param>
        /// <returns></returns>
        public string LableA(string Content)
        {
            return string.Format(BasicsCode("a"), Content);
        }

        /// <summary>
        /// 创建A标签
        /// </summary>
        /// <param name="Content"></param>
        /// <param name="Class"></param>
        /// <returns></returns>
        public string LableA(string Content, string ClassName)
        {
            return string.Format(BasicsCode("a", AttributeCode("class", ClassName)), Content);
        }

        /// <summary>
        /// 创建A标签
        /// </summary>
        /// <param name="Content"></param>
        /// <param name="Class"></param>
        /// <returns></returns>
        public string LableA(string Content, string ClassName, string Href)
        {
            return string.Format(BasicsCode("a", AttributeCode("class", ClassName) + AttributeCode("href", Href)), Content);
        }

        /// <summary>
        /// 创建H标签 可设置参数1-6
        /// </summary>
        /// <param name="Content"></param>
        /// <param name="HLableCount"></param>
        /// <returns></returns>
        public string LableH(string Content, int HLableCount)
        {
            return string.Format(BasicsCode("h" + HLableCount), Content);
        }

        /// <summary>
        /// 创建H标签 可设置参数1-6
        /// </summary>
        /// <param name="Content"></param>
        /// <param name="HLableCount"></param>
        /// <returns></returns>
        public string LableH(string Content, int HLableCount, string ClassName)
        {
            return string.Format(BasicsCode("h" + HLableCount, AttributeCode("class", ClassName)), Content);
        }

        /// <summary>
        /// 加粗标签
        /// </summary>
        /// <param name="Content"></param>
        /// <returns></returns>
        public string LableStrong(string Content)
        {
            return string.Format(BasicsCode("strong"), Content);
        }

        /// <summary>
        /// 加粗标签
        /// </summary>
        /// <param name="Content"></param>
        /// <param name="ClassName"></param>
        /// <returns></returns>
        public string LableStrong(string Content, string ClassName)
        {
            return string.Format(BasicsCode("strong", AttributeCode("class", ClassName)), Content);
        }

        /// <summary>
        ///  创建lightbox支持
        /// </summary>
        /// <param name="Imgurl"></param>
        /// <param name="LightBoxHref"></param>
        /// <returns></returns>
        public string LableLightBox(string Imgurl, string LightBoxHref)
        {
            return string.Format(BasicsCode("a", AttributeCode("data-lightbox", "image") +
                AttributeCode("href", LightBoxHref)
                ), LableImg(Imgurl));
        }
    }
}